home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
4.1
/
Browser-improvements.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
5KB
|
118 lines
" NAME Browser-improvements
AUTHOR knight@mrco.carleton.ca (Alan Knight) and mario@cs.man.ac.uk (Mario Wolczko)
FUNCTION New/improved features for opening browsers
ST-VERSION 4.1
PREREQUISITES
CONFLICTS Browser>pickAClass:, Browser>selectorMenu
DISTRIBUTION world
VERSION 1
DATE 17 Oct 1991
SUMMARY
Here are a couple of minor improvements for ParcPlace Smalltalk
Release 4.1. The first allows you to spawn a class/hierarchy browser from a
message list browser, letting you easily browse a class that occurs in
a senders or implementors list. The second improves the 'find class'
feature, mostly by not requiring the trailing wildcard. Both are
modified by me from the standard system distribution, the second with
improvements suggested by Danny Epstein. (Ported to 4.1 by Mario Wolczko;
also added spawn of hierarchy browser.)
Alan Knight knight@mrco.carleton.ca +1 613 788 2600x5783 Support
Dept. of Mechanical and Aeronautical Engineering the
Carleton University, Ottawa, Ontario, Canada, K1S 5B6 LPF
Mario Wolczko
Dept. of Computer Science Internet: mario@cs.man.ac.uk
The University uucp: mcsun!!uknet!!man.cs!!mario
Manchester M13 9PL JANET: mario@uk.ac.man.cs
U.K. Tel: +44-61-275 6146 (FAX: 6236)
"
'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 9 November 1992 at 6:45:08 pm'!
!Browser methodsFor: 'selector list'!
selectorMenu
"Answer a Menu of operations on message selectors to be
displayed when the operate menu button is pressed."
"Browser flushMenus"
selector == nil ifTrue: [^ nil].
MessageMenu == nil ifTrue:
[MessageMenu := PopUpMenu
labels: 'file out as...\hardcopy\spawn\senders\implementors\messages...\move to...\remove...' withCRs
lines: #(3 6)
values: #(fileOutMessage printOutMessage spawnMethod browseSenders browseImplementors browseMessages moveMethod removeMethod).
MessageMenu valueAt: 3 put: (PopUpMenu
labels: 'method\class\hierarchy' withCRs
values: #(spawnMethod spawnClass spawnHierarchy))].
^ MessageMenu! !
!Browser methodsFor: 'private-category functions'!
pickAClass: prompt
"Choose a class with a prompter. Bring up menu for wildcards.
Answer the an empty string if that's what the user returned or
if the user selects outside the menu, answer nil if the user picks
a name that does not match any class name.
Modified from the standard distribution to bring up
a menu for any ambiguous string which does not completely specify a class.
i.e. 'obj' gives a menu of (Object ObjectMemory)
but 'object' will bring you immediately to the class
Object."
| destClassName destClass namesToSearch |
destClassName := DialogView request: prompt initialAnswer: ParagraphEditor currentSelection.
destClassName = '' ifTrue: [^''].
"Allow finding the classes for global variables only if there are no wildcards at all. This
minimizes e.g. unexpectedly getting SystemDictionary when expecting SmalltalkCompiler "
namesToSearch := Smalltalk perform:
((destClassName includes: $*) ifTrue: [#classNames] ifFalse: [#keys]).
"Make two passes, the first time with an exact search, possibly allowing globals. If the
first pass finds an exact match, then return it, otherwise add a wildcard onto the end and
try again"
2 timesRepeat:
[| classes actualClassName |
Cursor execute showWhile:
[classes := namesToSearch select: [:cn | destClassName match: cn]].
classes size = 1
ifTrue: [actualClassName := classes detect: [:someItem | true]]. "Set>any not in base image."
classes size > 1
ifTrue:
[|chosenSelector|
(chosenSelector :=
(PopUpMenu labelList: (Array with: classes)) startUp) = 0
ifTrue: [^'']
ifFalse: [actualClassName := classes at: chosenSelector]].
actualClassName isNil
ifFalse:
[destClass := Smalltalk at: actualClassName asSymbol ifAbsent: [^nil].
meta ifTrue: [destClass := destClass class].
^destClass].
destClassName := destClassName , '*'.
namesToSearch := Smalltalk classNames]. "Second time through, no globals allowed"
^nil! !
!HierarchyBrowser class methodsFor: 'view creation'!
newPickClass
"Ask the user to name a class, then create and schedule a view
that is a browser for that class's hierarchy."
"HierarchyBrowser newPickClass"
| browser class |
class := (browser := Browser new meta: false) pickAClass: 'Browse what class?'.
class = '' ifTrue: [^self].
class isNil ifTrue:
[DialogView warn: 'No matching class'. ^self].
class isBehavior ifFalse: [class := class class].
class isMeta ifTrue: [class := class soleInstance].
^HierarchyBrowser openHierarchyBrowserFrom: (browser onClass: class)! !